package main

import (
	"fmt"
	"sync"
	"time"

	"github.com/go-redis/redis/v8"
)

// Logger 用于生成日志并发送到消息队列
func Logger(client *redis.Client, queueName string, wg *sync.WaitGroup) {
	defer wg.Done()

	for {
		// 模拟日志生成
		logMessage := fmt.Sprintf("Log entry at %s", time.Now().Format("2006-01-02 15:04:05"))
		err := PushMessage(client, queueName, logMessage)
		if err != nil {
			fmt.Printf("Failed to push log message: %v\n", err)
		} else {
			fmt.Printf("Log message pushed: %s\n", logMessage)
		}

		// 模拟日志生成频率
		time.Sleep(1 * time.Second)
	}
}
